package com.demo.controller;

import com.demo.feign.StockFeignClient;
import com.demo.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/order")
public class orderController {
 @Autowired
 private StockFeignClient stockFeignService;
 @Autowired
 private OrderService orderService;

 @GetMapping("/info")
 public String getstockInfo(String info){
     return  stockFeignService.test(info);
 }

 @RequestMapping("/placeOrder/rollback")
 public Boolean placeOrderRollback() {
  // product-2 扣库存时模拟了一个业务异常,
  orderService.placeOrder("1", "product-2", 1);
  return true;
 }

}
